package com.sora.sora.common.utils;

import org.springframework.stereotype.Component;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Component
public class StringUtils {

    public boolean isBlank(String str) {
        if (str == null || str.trim() == "") {
            return true;
        }
        return false;
    }

    public boolean nameCheck(String name) {

        String regName = "^[A-z\\u4E00-\\u9FFF][^\\s@!#\\$%\\^&\\*(),.，。<>《》;；'’:：'/“”\"]{1,9}$";
        Pattern pattern = Pattern.compile(regName);
        Matcher matcher = pattern.matcher(name);
        return matcher.matches();
    }

    public boolean passwordCheck(String password) {

        String regPassword = "^[a-zA-Z]\\w{7,16}$";
        Pattern pattern = Pattern.compile(regPassword);
        Matcher matcher = pattern.matcher(password);
        return matcher.matches();
    }
}
